//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Copyright 2012 Microsoft Corporation. All Rights Reserved
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.   
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Copyright 2012 Microsoft Corporation. All Rights Reserved
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.   
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

namespace Preflight.Client
{
    using System;
    using System.Globalization;
    using System.Xml;

    public static class EndpointTemplates
    {
        private static readonly XmlDocument templates = GetTemplatesDocument();

        public static string GetTemplate(string templateName)
        {
            var element = (XmlElement)templates.SelectSingleNode(string.Format(CultureInfo.InvariantCulture, "/templates/endpoint[@name='{0}']", templateName));
            var elementClone = (XmlElement)element.Clone();
            elementClone.SetAttribute("name", DateTime.Now.ToString(CultureInfo.InvariantCulture));
            return elementClone.OuterXml.Replace(">", ">\n\t");
        }

        private static XmlDocument GetTemplatesDocument()
        {
            var xml = new XmlDocument();
            xml.LoadXml(Templates.Endpoints);
            return xml;
        }

        public static class Names
        {
            public const string UnsecureHttp = "unsecurehttp";
            public const string WindowsAzureSource = "azure";
            public const string WindowsAuthHttpEndpoint = "winauthsecuredhttp";
            public const string PreflightSecurityHttpEndpoint = "preflightsecuredhttp";
            public const string Custom = "custom";
            public const string AcsSecuredServiceEndpoint = "acsuidpwd";
        }
    }
}
